<?php
Authenticate::requireAccounting();
$db = Db::getInstance();
$query = "SELECT * FROM ConfigInvoice WHERE display=1 ORDER BY createTime DESC";
$result = $db->query($query);
$rows = array();
while($row = $result->fetch_assoc()){
	$query = "SELECT * FROM Invoice WHERE id='{$row['invoiceId']}'";
	$result2 = $db->query($query);
	$row['invoice'] = $result2->fetch_assoc();
	$row['invoice']['package'] = Package::instance()->getOne($row['invoice']['packageId']);
	$rows[] = $row;
}
View::display('accounting/configInvoice', array('configInvoices'=> $rows));